//
//  ZH_CenterInfoTableViewCell.m
//  WisdomStar
//
//  Created by zhangliwen on 2018/10/25.
//  Copyright © 2018年 zhangliwen. All rights reserved.
//

#import "ZH_CenterInfoTableViewCell.h"
@interface ZH_CenterInfoTableViewCell()
@property (nonatomic,weak)UILabel *teleLabel;
@property (nonatomic,weak)UILabel *classLabel;
@property (nonatomic,weak)UILabel *addressLabel;
@property (nonatomic,weak)UILabel *levelLabel;
@end
@implementation ZH_CenterInfoTableViewCell

///创建
+(instancetype)cellWithTableView:(UITableView*)tableView
{
    static NSString *ID = @"ZH_CenterInfoTableViewCell";
    ZH_CenterInfoTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if(cell == nil){
        cell = [[ZH_CenterInfoTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
    }
    return cell;
}
///初始化
-(void)initDefault
{
    [self unShowClickEffect];
    //    self.bottomLongLineImage.hidden = NO;
}
- (void)loadSubviewConstraints{
    [self.teleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(FITSCALE(15));
        make.left.equalTo(self.contentView).offset(FITSCALE(22));
    }];
    [self.classLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.teleLabel.mas_bottom).offset(FITSCALE(15));
        make.left.equalTo(self.teleLabel);
    }];
    [self.addressLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.classLabel.mas_bottom).offset(FITSCALE(15));
        make.left.equalTo(self.teleLabel);
        make.right.equalTo(self.contentView).offset(FITSCALE(-22));
        make.bottom.equalTo(self.contentView).offset(FITSCALE(-15));
    }];
    [self.levelLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(FITSCALE(15));
        make.right.equalTo(self.contentView).offset(FITSCALE(-22));
    }];
}
- (void)updataUI:(NSDictionary *)dic{
    if (dic) {
        self.teleLabel.text = [NSString stringWithFormat:@"电话: %@",dic[@"mobile"]];
        self.classLabel.text = [NSString stringWithFormat:@"课程: %@",dic[@"name"]];
        self.addressLabel.text = [NSString stringWithFormat:@"地址: %@",dic[@"address"]];
        self.levelLabel.text = [NSString stringWithFormat:@"级别: %@",dic[@"level"]];
    }
}
#pragma mark - getter,setter
- (UILabel *)teleLabel{
    if (!_teleLabel) {
        UILabel *label = [UILabel createLabelWithText:@"电话: 11111111111" font:kFontSize_26];
        label.textColor = [UIColor colorWithHexString:@"#191919"];
        NSMutableAttributedString *attr = [[NSMutableAttributedString alloc]initWithString:label.text];
        NSDictionary *dic = @{NSFontAttributeName:kFontSize_26,NSForegroundColorAttributeName:[UIColor colorWithHexString:@"#555555"]};
        [attr setAttributes:dic range:[label.text rangeOfString: @"电话:"]];
        label.attributedText = attr;
        [self.contentView addSubview:_teleLabel = label];
    }
    return _teleLabel;
}
- (UILabel *)classLabel{
    if (!_classLabel) {
        UILabel *label = [UILabel createLabelWithText:@"课程: 语文、数学、综合" font:kFontSize_26];
        label.textColor = [UIColor colorWithHexString:@"#191919"];
        NSMutableAttributedString *attr = [[NSMutableAttributedString alloc]initWithString:label.text];
        NSDictionary *dic = @{NSFontAttributeName:kFontSize_26,NSForegroundColorAttributeName:[UIColor colorWithHexString:@"#555555"]};
        [attr setAttributes:dic range:[label.text rangeOfString: @"课程:"]];
        label.attributedText = attr;
        [self.contentView addSubview:_classLabel = label];
    }
    return _classLabel;
}
- (UILabel *)addressLabel{
    if (!_addressLabel) {
        UILabel *label = [UILabel createLabelWithText:@"地址: 四川省成都市高新区..." font:kFontSize_26];
        label.textColor = [UIColor colorWithHexString:@"#191919"];
        NSMutableAttributedString *attr = [[NSMutableAttributedString alloc]initWithString:label.text];
        NSDictionary *dic = @{NSFontAttributeName:kFontSize_26,NSForegroundColorAttributeName:[UIColor colorWithHexString:@"#555555"]};
        [attr setAttributes:dic range:[label.text rangeOfString: @"地址:"]];
        label.attributedText = attr;
        [label lableAutoLinefeed];
        [self.contentView addSubview:_addressLabel = label];
    }
    return _addressLabel;
}
- (UILabel *)levelLabel{
    if (!_levelLabel) {
        UILabel *label = [UILabel createLabelWithText:@"级别: V2教授" font:kFontSize_26];
        label.textColor = [UIColor colorWithHexString:@"#191919"];
        NSMutableAttributedString *attr = [[NSMutableAttributedString alloc]initWithString:label.text];
        NSDictionary *dic = @{NSFontAttributeName:kFontSize_26,NSForegroundColorAttributeName:[UIColor colorWithHexString:@"#555555"]};
        [attr setAttributes:dic range:[label.text rangeOfString: @"级别:"]];
        label.attributedText = attr;
        label.textAlignment = NSTextAlignmentRight;
        [self.contentView addSubview:_levelLabel = label];
    }
    return _levelLabel;
}
@end
